﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace eSchoolbag
{
	/// <summary>
	/// Interaction logic for Browser.xaml
	/// </summary>
	public partial class BrowserWindow : Window
	{
		static private BrowserWindow _browser = null;
		
		private BrowserWindow()
		{
			InitializeComponent();
		}

		static public BrowserWindow GetInstance()
		{
			if (_browser == null) 
				_browser = new BrowserWindow();

			return _browser;
		}

		public void ShowAndNavigate2(string title, string url)
		{
			try
			{
				this.Title = title;
				this.Visibility = Visibility.Visible;
				webBrowser.Navigate(url);
			}
			catch (Exception e)
			{
				MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
				this.Close();
			}
		}

		private void Window_Closed(object sender, EventArgs e)
		{
			_browser = null;
		}
	}
}
